package com.uriuniv.dao;

import java.sql.SQLException;
import java.util.List;

import org.springframework.jdbc.core.JdbcTemplate;

import com.uriuniv.domain.University;
import com.uriuniv.mapper.UniversityM;

public class UniversityD {

	private JdbcTemplate jdbcTemplate;

	public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
		this.jdbcTemplate = jdbcTemplate;
	}
	
	public List<University> getUnivList(){
		final String UNIVERSITY_LIST = "SELECT * FROM UNIVERSITY ORDER BY univ_name ";
		List<University> list = (List<University>)jdbcTemplate.query(UNIVERSITY_LIST, new UniversityM());
		return list;
	}
	
	public University getUniversity(String universityName) throws SQLException {
		final String UNIVERSITY = "SELECT * FROM UNIVERSITY WHERE UNIV_NAME = '" + universityName + "'";
		University university = (University)jdbcTemplate.queryForObject(UNIVERSITY, new UniversityM());
		return university;
	}
	
}
